<!--
 * @Author: 李瑞清
 * @Date: 2023-02-24 17:28:14
 * @LastEditors: 李瑞清 alger_li@163.com
 * @LastEditTime: 2023-04-10 10:59:56
 * @FilePath: \oms\page\followup\html\dataCenter\dataCenterNew.html
 * @Description:
-->
<!-- author: 汪孟苹 -->
<style>
    .datacenter .age {
        width: 50px;
    }

    .datacenter .footer {
        text-align: right;
        box-sizing: border-box;
        padding-top: 20px;
    }

    .datacenter .queue-btn {
        padding: 0;
    }

    /* .datacenter .queue{
        width: 500px;
    } */
</style>

<body>
<div class="datacenter panel panel-default" id="root">
    <div class="panel-heading">
        <h3 class="panel-title" data-language="true" data-language-key="dataCenterAllPatient">全部患者</h3>
    </div>
    <div class="panel-body dataCenter-wrap">
        <div class="form-horizontal">
            <el-form :inline="true" :model="searchForm" class="demo-form-inline">
                <!--					<el-form-item label="科研编号">-->
                <!--						<el-input v-model="searchForm.hisNo" placeholder="科研编号"></el-input>-->
                <!--					</el-form-item>-->
                <el-form-item label="姓名">
                    <el-input v-model="searchForm.patientName" placeholder="姓名"></el-input>
                </el-form-item>
                <el-form-item label="联系方式">
                    <el-input v-model="searchForm.phoneNum" placeholder="联系方式"></el-input>
                </el-form-item>
                <el-form-item label="选择队列">
                    <el-select :clearable="true" v-model="searchForm.queueId" placeholder="选择队列">
                        <el-option v-for="(item,index) in queueList" :label="item.queueName"
                                   :value="item.id"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="选择分级">
                    <el-select :clearable="true" v-model="searchForm.scaleAssessStatus" placeholder="选择分级">
                        <el-option label="高危" value="3"></el-option>
                        <el-option label="中危" value="2"></el-option>
                        <el-option label="低危" value="1"></el-option>
                    </el-select>
                </el-form-item>
                <!--					<el-form-item label="年龄范围">-->
                <!--						<el-input class="age" v-model="searchForm.yearStart" placeholder="岁"></el-input>-->
                <!--						<el-input class="age" v-model="searchForm.monthStart" placeholder="月"></el-input>- -->
                <!--						<el-input class="age" v-model="searchForm.yearEnd" placeholder="岁"></el-input>-->
                <!--						<el-input class="age" v-model="searchForm.monthEnd" placeholder="月"></el-input>-->
                <!--					</el-form-item>-->
                <el-form-item>
                    <el-button type="primary" @click="onSubmit">查询</el-button>
                </el-form-item>
            </el-form>
        </div>

        <el-table :data="table.data" border v-loading="table.loading" style="width: 100%">
            <!-- <el-table-column label="序号" align="center" prop="No" width="80">
                <template slot-scope="scope">
                    {{scope.$index+(table.current)+1}}
                </template>
            </el-table-column> -->
            <!--				<el-table-column width="150px" label="科研编号" align="center" prop="hisNo1">-->
            <!--					<template slot-scope="scope">-->
            <!--						{{scope.row.hisNo1||'-'}}-->
            <!--					</template>-->
            <!--				</el-table-column>-->
            <el-table-column width="180px" label="姓名" align="center" prop="patientName">
            </el-table-column>
            <el-table-column width="200px" label="联系方式" align="center" prop="phoneNum">
            </el-table-column>
            <el-table-column width="180px" label="年龄" align="center" prop="age">
            </el-table-column>
            <el-table-column width="150px" label="性别" align="center" prop="gender2">
            </el-table-column>
            <el-table-column width="180px" label="分级" align="center" prop="nczfxpj">
                <template slot-scope="scope">
                    <el-tag :type="'warning'" disable-transitions v-if="scope.row.scaleAssessStatus == '3'">
                        {{scope.row.scaleAssessStatus == 3 ? "高危":""}}
                    </el-tag>
                    <el-tag :type="'primary'" disable-transitions v-if="scope.row.scaleAssessStatus == '2'">
                        {{scope.row.scaleAssessStatus == 2 ? "中危":""}}
                    </el-tag>
                    <el-tag :type="'success'" disable-transitions v-if="scope.row.scaleAssessStatus == '1'">
                        {{scope.row.scaleAssessStatus == 1 ? "低危":""}}
                    </el-tag>
                </template>
            </el-table-column>
            <el-table-column class-name="queue" label="所在队列" align="center" prop="followQueueName">
                <template slot-scope="scope">
                    <template v-for="(scheme,index) in scope.row.userInfo" :key="index">
                        <el-button class="queue-btn" @click="handleToDetail(scope.row,scheme)"
                                   type="text">{{scheme.followQueueName}}
                        </el-button>
                    </template>
                    <!-- <el-button type="text" @click="handleToDetail(scope.row)">{{scope.row.followQueueName}}</el-button> -->
                </template>
            </el-table-column>
            <!-- <el-table-column label="创建时间" align="center" prop="followQueueName">
            </el-table-column> -->
            <!-- <el-table-column label="操作" align="center">
                <template slot-scope="scope">
                    <el-button size="mini" type="warning" @click="handleAddQueue(scope.row)">添加到系统</el-button>
                    <el-button size="mini" type="primary" @click="handleChecked(scope.row)">查看</el-button>
                </template>
            </el-table-column> -->
        </el-table>
        <div class="footer">
            <el-pagination background @current-change="handleChangePage" layout="total,prev, pager, next"
                           :total="table.total">
            </el-pagination>
        </div>

    </div>
</div>

</body>
<script type="text/javascript">
    // require(['jquery', 'fu/app/dataCenter/dataCenter'], function ($, $dataCenter) {
    // 	$dataCenter.init()
    // });
    require(['bbcare'], function ($bb, $) {
        var URL = $bb.baseUrl("followup")
        var vm = new Vue({
            el: '#root',
            data: {
                //队列
                queueList: [],
                searchForm: {
                    queueId: '',
                    phoneNum: '',
                    patientName: '',
                    hisNo: '',
                    yearStart: '',
                    monthStart: '',
                    yearEnd: '',
                    monthEnd: '',
                    scaleAssessStatus: ''
                },
                table: {
                    current: 1,
                    size: 10,
                    total: 0,
                    data: [],
                    loading: false,
                },
            },
            created: function () {
                this.getTableData()
                this.ajaxQueue()
            },
            methods: {

                getParams(searchForm) {
                    let param = {
                        // args: {
                        // 	start: this.table.current,
                        // 	length: this.table.size
                        // },
                        page: this.table.current,
                        rows: this.table.size,
                        flag: 2,
                        userStatus: 0
                    }
                    if (searchForm.hisNo) {
                        param.hisNo = searchForm.hisNo
                    }
                    if (searchForm.patientName) {
                        param.patientName = searchForm.patientName
                    }
                    if (searchForm.phoneNum) {
                        param.phoneNum = searchForm.phoneNum
                    }
                    if (searchForm.queueId) {

                        param.queueId = searchForm.queueId
                    }
                    if (searchForm.scaleAssessStatus) {
                        param.scaleAssessStatus = searchForm.scaleAssessStatus
                        // if (searchForm.scaleAssessStatus == "1") {
                        //
                        //     param.scaleAssessStatus = 1
                        // } else if (searchForm.scaleAssessStatus == "2") {
                        //     param.scaleAssessStatus = 2
                        //
                        // } else if (searchForm.scaleAssessStatus == "3") {
                        //
                        //     param.scaleAssessStatus = 3
                        // }
                    }
                    if (searchForm.yearStart && searchForm.yearEnd) {
                        param.ageFrom = parseInt(searchForm.yearStart * 12)
                        param.ageTo = parseInt(searchForm.yearEnd * 12)
                    }
                    if (searchForm.monthStart && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.monthStart)
                        param.ageTo = parseInt(searchForm.monthEnd)
                    }
                    if (searchForm.monthStart && searchForm.yearEnd) {
                        param.ageFrom = parseInt(searchForm.monthStart)
                        param.ageTo = parseInt(searchForm.yearEnd * 12)
                    }
                    if (searchForm.yearStart && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.yearStart * 12)
                        param.ageTo = parseInt(searchForm.monthEnd)
                    }
                    if (searchForm.yearStart && searchForm.yearEnd && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.yearStart * 12)
                        param.ageTo = parseInt(searchForm.yearEnd * 12) + parseInt(searchForm.monthEnd)
                    }
                    if (searchForm.monthStart && searchForm.yearEnd && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.monthStart)
                        param.ageTo = parseInt(searchForm.yearEnd * 12) + parseInt(searchForm.monthEnd)
                    }
                    if (searchForm.yearStart && searchForm.yearEnd && searchForm.monthStart && searchForm.monthEnd) {
                        param.ageFrom = parseInt(searchForm.yearStart * 12) + parseInt(searchForm.monthStart)
                        param.ageTo = parseInt(searchForm.yearEnd * 12) + parseInt(searchForm.monthEnd)
                    }
                    return param
                },
                // 查询队列
                ajaxQueue() {
                    let that = this
                    $bb.ajax({
                        url: URL + "followup/service/queue/followQueueListQuery",
                        success: function (data) {
                            if (data.success) {
                                that.queueList = data.data.rows
                            }
                        }
                    })
                },

                // 查询数据
                getTableData() {
                    let that = this
                    that.table.loading = true
                    $bb.ajax({
                        url: URL + 'followup/service/patient/queryPatientListDataCenter',
                        data: JSON.stringify({
                            data: that.getParams(that.searchForm)
                        }),
                        success: function (res) {
                            that.table.total = res.total
                            that.table.data = res.rows
                            that.table.loading = false
                        }
                    })

                },


                onSubmit() {
                    this.table.current = 1
                    this.getTableData()
                },


                handleChangePage(page) {
                    // this.table.current = (page - 1) * this.table.size
                    this.table.current = page
                    this.getTableData()
                },

                handleToDetail: function (row, scheme) {
                    let params = {
                        followQueueId: scheme.followQueueId,
                        imgSrc: row.gender == 'N' || row.gender == 1 ? 'page/followup/imgs/comm/boy.png' : 'page/followup/imgs/comm/girl.png',
                        patientId: row.patientId,
                        patientName: row.patientName,
                        patientSchemeId: scheme.patientSchemeId,
                        queuename: scheme.followQueueName,
                    }
                    $bb.openPage("outPatient", params)
                }
            }
        })
    })
</script>
